<?php
class Categorymanager_Model_Insertcategory implements Categorymanager_Model_Mainable{
    
    private $core_controller_notnull;
    private $core_controller_checktoken;
    
    private $excepted_result = 1;
    
    private $categorymanager_data_insertcategorysettings;
    private $categorymanager_data_insertcategorymetavalues;
    private $categorymanager_data_insertcategorycontentvalues;
    
    private $insert_category_settings_result;
    private $insert_category_meta_values_result;
    private $insert_category_content_values_result;
    
    public function main(array $variables = null) {
        $this->core_controller_checktoken = new Core_Controller_Tokencheckout;
        $this->core_controller_checktoken->main($variables['post']);
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_notnull->main($variables);
        
        $this->categorymanager_data_insertcategorysettings = new Categorymanager_Data_Insertcategorysettings;
        $this->categorymanager_data_insertcategorymetavalues = new Categorymanager_Data_Insertcategorymetavalues;
        $this->categorymanager_data_insertcategorycontentvalues = new Categorymanager_Data_Insertcategorycontentvalues;
        
        $this->insert_category_settings_result = $this->categorymanager_data_insertcategorysettings->main($variables);
        $this->insert_category_meta_values_result = $this->categorymanager_data_insertcategorymetavalues->main($variables);
        $this->insert_category_content_values_result = $this->categorymanager_data_insertcategorycontentvalues->main($variables);
        
        if(
                ($this->insert_category_settings_result == $this->excepted_result) &&
                ($this->insert_category_meta_values_result == $this->excepted_result) &&
                ($this->insert_category_content_values_result == $this->excepted_result)
                ){
            header("Location: ".SITE_ROOT."zarzadzaj-kategoriami.html");
        }
        else {
            header("Location: ".SITE_ROOT."zarzadzaj-kategoriami.html");
        }
    }

}
